a = 'GET http://www.weather.com.cn/data/sk/101280101.html HTTP/1.0\r\nAccept-Language: en-us\r\n'
b = 'Host: www.weather.com.cn:80\r\nAccept: */*\r\nMozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36\r\nConnection: close\r\n\r\n'
print(a..b)

print("connect tcp_client")
tcp_client = net.createConnection(net.TCP, 1)

tcp_client:on("receive", function(sck, c) 
    print("tcp_client receive") 
    print(c) 
end)
tcp_client:on("connection", function(sck, c) 
    print("tcp_client connection") 
    request_msg = {}
    request_msg['Request URL'] = 'http://www.weather.com.cn/data/sk/101280101.html'
    request_msg['Request Method'] = 'GET'
    request_msg['Host'] = 'www.weather.com.cn'
    request_msg['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'

    ok,json = pcall(cjson.encode, request_msg)
    if ok then
        print(json)
        sck:send(a..b) 
    else
        print("failed to encode json")
    end
    
end)

tcp_client:connect(80, 'www.weather.com.cn')
